package br.com.monografia;

import br.com.monografia.dao.PerfilDao;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class PerfilActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.perfil);
		final EditText nome = (EditText) findViewById(R.id.nome);
		final EditText peso = (EditText) findViewById(R.id.idade);
		Button bsalva = (Button) findViewById(R.id.bfim);
		
		
		bsalva.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				long id = 0;
				try {
					PerfilDao perfilDao = new PerfilDao(PerfilActivity.this);
					id = perfilDao.inserir(nome.getText().toString(), peso.getText().toString());
					Toast toast = Toast.makeText(PerfilActivity.this, "Banco criado com Sucesso no id: " +id+"", Toast.LENGTH_SHORT);
				    toast.show();
				    Intent tela = new Intent();
					tela.setClass(PerfilActivity.this, DiabetesActivity.class);
					startActivity(tela);				
				} catch (Exception e) {
					Toast toast = Toast.makeText(PerfilActivity.this, "ERRO ao inserir!"+e.getMessage().toString()+"", Toast.LENGTH_SHORT);
				    toast.show();				
				}				
			}
		});
		
		

	}
	

	

}
